// JavaScript Document
var oHtml = document.documentElement;
getSize();
window.onresize = function(){
	getSize();
}
function getSize(){
	var screenWidth = oHtml.clientWidth;
	oHtml.style.fontSize = screenWidth/(750/36) + 'px';//  /100*2
} 
$(function(){
   var url="lottery";//http://139.196.33.153:8800/queryNumber
   var data={
	  empId:'',
	  empName:''
	}
	$('.con_1').css('height',$(window).height());
	$('.b').on("keyup blur",(function (e){
		var e = e || event,
	   keycode = e.which || e.keyCode;
	   if (keycode==13) {
		Switch();
	   }
     }));
	 $('.b').on("blur",Switch);
function saiAjax(url,data){
   $.ajax({  
	   url: url,
	   type: 'get',  
	   dataType: 'json',
	   data:data,
	   cache: false,     
	   error: erryFunction,  //错误执行方法    
	   success: succFunction //成功执行方法    
   })
}
function Switch(){
	data.empId=$("#id").val();
	data.empName=$("#name").val();
	data.action='lottery'
	saiAjax(url,data);
}
function erryFunction(error){
    alert(error['error']);  
	}
function succFunction(json){
	var result=json['data']['result'];
	if(result=="fail"){
		var mess=json['data']['message'];
		alert(mess);
	}else{
		var lotteryid=json['data']['employee']['lotteryId'];
		if(lotteryid!="undefined"){
			location.href = "prize.html?id="+lotteryid;
		}
	}
	
  }
});
